package dumpDb

import (
	"github.com/spf13/viper"
	"log"
)

type DumpDbCfg struct {
	DockerMysql DockerMysql `value:"${dockerMysql}"`
	Mysql       Mysql       `value:"${mysql}"`
	Ssh         Ssh         `value:"${ssh}"`
}
type DockerMysql struct {
	InDocker bool   `value:"${inDocker}"`
	ImageId  string `value:"${imageId}"`
}
type Mysql struct {
	Url   string `value:"${url}"`
	Port  string `value:"${port}"`
	Uname string `value:"${uname}"`
	Pwd   string `value:"${pwd}"`
	Db    string `value:"${db}"`
}
type Ssh struct {
	Url   string `value:"${inDocker}"`
	Uname string `value:"${uname}"`
	Pwd   string `value:"${pwd}"`
}

var DumpDbCfgs DumpDbCfg

func init() {
	v := viper.New()
	v.SetConfigFile("../db.yaml")
	err := v.ReadInConfig()
	if err != nil {
		log.Fatal(err, "读取配置文件失败")
	}
	err = v.Unmarshal(&DumpDbCfgs)
	if err != nil {
		log.Fatal(err, "反序列化到结构体失败")
	}
}
